package edu.gatech.oad.antlab.person;

public class Person2 {
    /** Holds the persons real name */
    private static String name= "person2";
	 /**
	 * The constructor, takes in the persons
	 * name
	 * @param pname the person's real name
	 */
	 public Person2(String pname) {
	   name = pname;
		//Person2 person= new Person2(name);
	 }
	/**
	 * This method should take the string
	 * input and return its characters in
	 * random order.
	 * given "gtg123b" it should return
	 * something like "g3tb1g2".
	 *
	 * @param input the string to be modified
	 * @return the modified string
	 */
	private static String calc(String input) {
	  //Person 2 put your implementation here
	  StringBuilder text = new StringBuilder(input);
 
    char temp;
    int  switchWith;
    for(int i=0; i<text.length(); i++)
    {
      temp = text.charAt(i);
      switchWith = (int)Math.floor(Math.random()*text.length());
      text.setCharAt(i, text.charAt(switchWith));
      text.setCharAt(switchWith, temp);
    }
    return text.toString();
	}
	/**
	 * Return a string rep of this object
	 * that varies with an input string
	 *
	 * @param input the varying string
	 * @return the string representing the 
	 *         object
	 */
	public static String toString(String input) {
	  return name + calc(input);
	}

}
